#include <iostream>
#include <list>
using namespace std;

void show_list(list<int> L)
{ list<int>::iterator p;
  for(p=L.begin(); p!=L.end(); p++)
    cout << *p << " ";
  cout << endl;
}    

int main()
{ int a[4]={12,15,65,13};
    
  list<int> L(a,a+4); 
  
  L.push_front(50);
  L.push_front(40);
  L.push_back(56);
  
  L.push_front(34);
  L.push_back(45);
  L.push_front(30);
  L.push_front(20);
  
  show_list(L);
  
  cout << L.front() << " " << L.back() << " " << L.size() << endl; 

  L.pop_front();
  L.pop_back();
  
  L.back() = 77;
  show_list(L);
  cout << L.front() << " " << L.back() << " " << L.size() << endl; 
  
  list<int>::iterator p;
  
  p = L.begin();
  ++p; ++p;
  
  cout << *p << endl;
  
  
  
  return 0;
}    
